package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.SkinPackageEntity;
import com.zw.yzk.kabu.data.network.service.SkinService;
import com.zw.yzk.kabu.data.network.task.SkinPackageTask;
import com.zw.yzk.kabu.data.network.task.Task;
import rx.Observable;
import rx.functions.Func1;

import javax.inject.Inject;

/**
 * Created by skydar on 2017/4/14.
 */

public class SkinPackageRepository extends CommonRepository {

    @Inject
    public SkinPackageRepository() {

    }

    @Override
    protected Observable connectServer(Task task) {
        SkinService service = ServiceGenerator.createService(SkinService.class);
        SkinPackageTask skinTask = (SkinPackageTask) addToken(task);

        return service.getSkinPackage(
                skinTask.userId,
                skinTask.accessToken,
                skinTask.packageId);
    }

    @Override
    protected Func1<SkinPackageEntity, Observable> getServerData() {
        return new Func1<SkinPackageEntity, Observable>() {
            @Override
            public Observable call(SkinPackageEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
